﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Common;

namespace WoodManager.UI
{
    public partial class FormDoiTenThanhPhan : Form
    {
        ConnectManager cm = new ConnectManager();
        string sHMSPID = ""; 
        public FormDoiTenThanhPhan()
        {
            InitializeComponent();
        }

        private void FormDoiTenThanhPhan_Load(object sender, EventArgs e)
        {

        }

        public void setText(string hmspid, string nameOld)
        {
            txtTenCu.Text = nameOld;
            sHMSPID = hmspid;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                SqlCommand sqlUpdate = new SqlCommand("Update DeXuatVan set ThanhPhan= '" + txtTenMoi.Text + "' where HMSPID = '" + sHMSPID + "' and ThanhPhan = '" + txtTenCu.Text + "'", cm.conn);
                if (cm.conn.State == ConnectionState.Closed)
                    cm.conn.Open();
                sqlUpdate.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cm.conn.Close();
            this.Dispose();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
